package com.cst.intercepterdemo.chain.node;

import com.cst.intercepterdemo.context.IInterceptContext;
import com.cst.intercepterdemo.intercepter.IRequestIntercepter;

/**
 * <ul>
 * <li>文件名称 : com.cst.intercepterdemo.chain.node.DefaultChainNode
 * </li>
 * <li>版权所有 : 版权所有(C)2016-2020</li>
 * <li>公 司 : CST</li>
 * <li>创建时间 : 2016/12/2</li>
 * <li>修改记录 : </li>
 * </ul>
 * 类说明：默认责任连节点
 *
 * @author Allen
 * @version 1.0
 */
public class DefaultChainNode extends AbstractIntercepterChainNode {

    private IRequestIntercepter intercepter;

    public DefaultChainNode(IRequestIntercepter intercepter) {
        if(intercepter==null){
            throw new RuntimeException();
        }
        this.intercepter = intercepter;
    }

    public DefaultChainNode(IIntercepterChainNode next,
                            IRequestIntercepter intercepter) {
        super(next);
        if(intercepter==null){
            throw new RuntimeException();
        }
        this.intercepter = intercepter;
    }

    @Override
    public boolean intercept(IInterceptContext context) {
       return intercepter.doIntercept(context);
    }
}
